$(function () {
    load();
});
function load(currentPage) {
    $.post("/music/musicList/findMusicListByPage",{currentPage:currentPage},function (data) {
        console.log(data);
        if (data.list!=null){
            $musicList = $("#musicList");
            var list = "";
            for (var i = 0; i < data.list.length; i++) {
                var li = " <li>" +
                    "            <a href='musicInList.html?mlid="+data.list[i].mlid+"' class='img'>" +
                    "              <img src='../"+data.list[i].musiclistimg+"' style='width: 100%;height: 100%'>" +
                    "              <span class='mask'></span>" +
                    "              <i class='icon-play'></i>" +
                    "            </a>" +
                    "            <div class='info'>" +
                    "              <div class='title'>" +
                    "                <a href='musicInList.html?mlid="+data.list[i].mlid+"'>"+data.list[i].musiclistname+"</a>" +
                    "                <i class='con-sprite'></i>" +
                    "              </div>" +
                    "            </div>" +
                    "          </li>"
                list += li;
            }
            $musicList.html(list);
            $switch = $("#switch");
            var btn ="";
            //上一页
            var prePage = data.currentPage - 1;
            if(prePage < 1){
                prePage = data.totalPage;
            }
            btn += "<a href='javascript:load("+prePage+");' class='slider-prev' id='prev'><i class='icon-sprite'></i></a>";
            //下一页
            var nextPage = data.currentPage + 1;
            if (nextPage > data.totalPage){
                nextPage = 1;
            }
            btn += " <a href='javascript:load("+nextPage+");' class='slider-next' id='next'><i class='icon-sprite'></i></a>";
            $switch.html(btn);
        }
    })
}